package per.sen.shopping.infrastructure.common.response;

import lombok.Data;
import java.util.LinkedHashMap;


/**
 * @Describe: 统一响应体
 * @Author: LYS
 * @DateTime: 2023/11/26 18:59
 */
@Data
@SuppressWarnings("unused")
public class ApiResponse extends LinkedHashMap<String,Object> {
    private final static String CODE_TAG = "code";
    private final static String MSG_TAG = "msg";
    private final static String DATA_TAG = "data";


    public ApiResponse (Integer code ,String msg,Object data) {
        super(3);
        super.put(CODE_TAG,code);
        super.put(MSG_TAG,msg);
        super.put(DATA_TAG,data);
    }


    public static  ApiResponse success(Object data) {
       return  new ApiResponse(HttpStatus.SUCCESS.getCode(),HttpStatus.SUCCESS.getMsg(),data);
    }
    public static  ApiResponse error(String msg,Object data) {
        return new ApiResponse(HttpStatus.INTERNAL_SERVER_ERROR.getCode(), msg,data);
    }

    public static  ApiResponse error(Integer code, String msg) {
        return new ApiResponse(code, msg,null);
    }


  


}
